from api import Graph
# from drives.tinydb import TinyDrv
# from drives.graphlite import SqliteDrv
from drives.arangodb import ArangoDrv

from pydantic import BaseModel, Field

class Man(BaseModel):
    """定义人类"""
    name: str = Field(title="姓名")
    age: int = Field(title="年龄")

class ManRef(BaseModel):
    """人与人的关系"""
    name:str = Field(title="文本")
    src: Man = Field(title="起始节点")
    tar: Man = Field(title="终止节点")

# g = Graph(SqliteDrv("test.db"))
g = Graph(ArangoDrv("root/dcii.org.cn"))

# M = g.getTag("Man")
m = Man(name="王五",age=23)
m2 = Man(name="张三",age=31)
m3 = Man(name="马六",age=44)

print(g.createTag(Man))
print(g.createRef(ManRef))

n1 = g.createNode("Man", data=m)
n2 = g.createNode("Man", data=m2)
n3 = g.createNode("Man", data=m3)
print(n1, n2, n3)
g.createEdge("ManRef", n1, n2)
g.createEdge("ManRef", n2, n3)